package com.frinder.seata.account.service;

import com.frinder.seata.data.base.Result;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @ClassName CallOrderFallbackFactory
 * @Description 调用订单服务熔断机制
 * @Author frinder
 * @Date 2020/8/18 11:06
 * @Verion 1.0
 */
@Slf4j
@Component
public class CallOrderFallbackFactory implements FallbackFactory<CallOrderService> {
    @Override
    public CallOrderService create(Throwable e) {
        return orderId -> {
            log.error("订单服务熔断生效，订单[{}]，失败原因[{}]", orderId, e.getMessage());
            return Result.selfFail(e.getMessage());
        };
    }
}
